<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var isSymmetric = function (root) {
      const traversal = (left, right) => {
        if (!left && !right) {
          return true
        }
        if (!left || !right || left.val !== right.val) {
          return false
        }
        return traversal(left.left, right.right) && traversal(left.right, right.left)
      }
      return traversal(root, root)
    };
    console.log(isSymmetric([1, 2, 2, 3, 4, 4, 3]));
  </script>
</body>

</html>